package dl.bukkit.myststus.function.trigger;

import dl.bukkit.myststus.vexshow.AbstractVexHud;
import org.bukkit.event.Event;

import java.util.ArrayList;
import java.util.List;

public abstract class TriggerHud<E extends Event> implements Trigger<E> {

    private final List<AbstractVexHud> list = new ArrayList<>();

    @Override
    public void remove(E event) {
        list.forEach(hud -> hud.removeHud(getPlayer(event), getTarget(event)));
    }

    @Override
    public void send(E event) {
        list.forEach(hud -> hud.sendHud(getPlayer(event), getTarget(event)));
    }

    public final void addHud(AbstractVexHud vexHud) {
        this.list.add(vexHud);
    }

    public List<AbstractVexHud> getList() {
        return list;
    }
}
